package com.study.controller.user;

import com.study.dto.CommentDTO;
import com.study.dto.CommentOrderDTO;
import com.study.entity.Comment;
import com.study.result.Result;
import com.study.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/comment")
@Api(tags = "评论相关接口")
@Slf4j
public class CommentController {

    @Autowired
    OrderService orderService;

    /**
     * 评价订单
     * @param commentOrderDTO
     * @return
     */
    @PostMapping("/commentOrder")
    @ApiOperation(value = "评价订单")
    public Result<String> commentOrder(@RequestBody CommentOrderDTO commentOrderDTO){
        orderService.commentOrder(commentOrderDTO);
        return Result.success("评论成功");
    }

    /**
     *
     * @param commentDTO
     * @return
     */
    @PostMapping("/getCommentList")
    @ApiOperation(value = "条件获取评论列表")
    public Result<List<Comment>> getCommentList(@RequestBody CommentDTO commentDTO){
        log.info("条件获取评论列表:commentDTO:{}",commentDTO);
        List<Comment> commentList = orderService.getCommentList(commentDTO);
        return Result.success(commentList);
    }
}
